#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

void scan_arr(int* arr, int x)
{
	int i = 0;
	for (i = 0;i < x;i++)
		scanf("%d", &arr[i]);
}

void connect_arr(int arr1[],int n,int* arr2,int m,int * arr_sum)
{
	int i = 0;
	int t = 0;
	int x = 0;
	int y = 0;
		while (x<n && y<m)
		{
			if (arr1[x] >= arr2[y])
			{
				arr_sum[t] = arr2[y];
				y++;t++;
			}
			else
			{
				arr_sum[t] = arr1[x];
				x++;t++;
			}
		}
		if (x == n)
			for (;t < n + m;t++,y++)
				arr_sum[t] = arr2[y];
		else
			for (;t < n + m;t++,x++)
				arr_sum[t] = arr1[x];
}

void print_arr(int* arr, int n)
{
	int i = 0;
	for (i = 0;i < n;i++)
		printf("%d ", arr[i]);
}

int main()
{
	int arr1[1000] = { 0 };
	int arr2[1000] = { 0 };
	int arr_sum[2000] = { 0 };
	int n = 0;
	int m = 0;
	scanf("%d %d", &n, &m);
	scan_arr(arr1, n);
	scan_arr(arr2, m);
	connect_arr(arr1, n,arr2,m, arr_sum);
	print_arr(arr_sum, n + m);
	return 0;
}